<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>文件上传</title>
		[#include "/html/include/easyuicss.html" /]
		<link rel="stylesheet" type="text/css" href="${app }/static/jquery-file-upload/css/jquery.fileupload.css">
		<link rel="stylesheet" type="text/css" href="${app }/static/jquery-file-upload/css/demo.css">
		[#include "/html/include/easyuijs.html" /]
		<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
		<script type="text/javascript" src="${app }/static/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
		<script type="text/javascript" src="${app }/static/jquery-file-upload/js/jquery.iframe-transport.js"></script>
		<script type="text/javascript" src="${app }/static/jquery-file-upload/js/jquery.fileupload.js"></script>
		<script type="text/javascript" src="${app }/static/jquery-file-upload/js/jquery.fileupload-process.js"></script>
		<script type="text/javascript" src="${app }/static/jquery-file-upload/js/jquery.fileupload-validate.js"></script>
		<script type="text/javascript" src="${app }/static/jquery-file-upload/js/jquery.fileupload-ui.js"></script>
	</head>
	<body>
		<form id="fileForm" method="post" style="padding: 10px;">
			<a href="javascript:;" class="easyui-linkbutton fileinput-button"
			   data-options="iconCls:'icon-add'" style="width:80px">
				选择文件
				<input id="fileupload" type="file" name="files" multiple />
			</a>
			<div id="files" style="margin: 5px 0px 5px 0px;"></div>
			<div id="progress" class="progress-bar"></div>
			<div class="edit-btn-group">
				<a href="javascript:;" class="easyui-linkbutton"
				   data-options="iconCls:'icon-cancel'" style="width:80px"
				   onclick="closeWindow();">关闭</a>
			</div>
		</form>
	</body>
    <script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		function closeWindow(){
			parent.layer.close(index);
			parent.frames[parent.iframeName].window.reloadFiles();
		}
		$(function () {
			$('#fileupload').fileupload({
				url: '${app}/sysmgr/file/upload.do',
				dataType: 'json',
				Type: 'POST',
				paramName: 'files',
				formData: {moduleName: '文件上传', remark: '文件上传'},
				autoUpload: true,
				acceptFileTypes: /(\.|\/)(gif|jpe?g|png|xlsx)$/i,
				maxFileSize: 99 * 1024 * 1024, //单位B
				minFileSize: 5,
				maxNumberOfFiles: 50,
				messages: {
					maxFileSize: 'File exceeds maximum allowed size of 99MB',
					acceptFileTypes: 'File type not allowed'
				},
				done: function (e, data) {
					//alert(JSON.stringify(data));
					//alert(data.result.fileName);
					if (data.result.result == 1) {
						$('<p/>').text("文件【"+data.result.fileName+"】"+data.result.msg).appendTo('#files');
					}
				},
				progressall: function (e, data) {
					var progress = parseInt(data.loaded / data.total * 100, 10);
					$('#progress').css(
							'width',
							progress + '%'
					);
				}
			});

			//可以如下绑定事件
			//$('#fileupload').bind('fileuploadchange', function (e, data) {});

		});
    </script>
</html>